﻿using rpc_service.core.registry;

namespace rpc_service.core.poll;

public class RandomPoll : Poll
{
    public RandomPoll(Dictionary<string, Services> tempServices) : base(tempServices)
    {
    }

    public override string GetUrl(string serviceName)
    {
        if (!services.ContainsKey(serviceName))
        {
            return "";
        }
        
        List<Service> service = services[serviceName].ServiceList;

        Random r = new Random();
        return service[r.Next(service.Count)].Url;
    }
}